package cn.rokhdelar.ams.base;

import lombok.Data;

/**
 * @author 范书铭
 * @date 2025年04月24日 18:02
 */
@Data
public class CustomResponse<T> {
    String message;
    Integer code;
    T data;

    public CustomResponse() {
    }

    public CustomResponse(Integer code, String message, T o) {
        this.message = message;
        this.code = code;
        this.data = o;
    }

    public static <T> CustomResponse<T> success(T data) {
        CustomResponse<T> result = new CustomResponse<T>();
        result.code = 200;
        result.data = data;
        result.message = "请求成功";
        return result;
    }

    public static <T> CustomResponse<T> success( ) {
        CustomResponse<T> result = new CustomResponse<T>();
        result.code = 200;
        result.message = "请求成功";
        return result;
    }
    public static <T> CustomResponse<T> error(String message ) {
        CustomResponse<T> response = new CustomResponse<T>();
        response.code = 500;
        response.message = message;
        return response;
    }
    public static <T> CustomResponse<T> error( ) {
        CustomResponse<T> response = new CustomResponse<T>();
        response.code = 500;
        response.message = "系统错误";
        return response;
    }
}
